<HTML><HEAD><TITLE>current_stream(-Name, -Mode, ?Stream)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Obsolete</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>current_stream(-Name, -Mode, ?Stream)</H1>
Succeeds if there is currently an open stream Stream open to the file Name
in the mode Mode. This predicate is obsolete, use current_stream/1 and
get_stream_info/3 instead.


<DL>
<DT><EM>Name</EM></DT>
<DD>Filename (atom or string), contents of string stream                (string) or variable.
</DD>
<DT><EM>Mode</EM></DT>
<DD>One of the atoms read, write, update, string or a variable.
</DD>
<DT><EM>Stream</EM></DT>
<DD>Physical stream number (integer), or a variable.
</DD>
</DL>
<H3>This built-in predicate is obsolete!</H3>
<H2>Description</H2>
   Unifies Name with the file name and Mode with the mode of the stream
   Stream.  If Stream is a variable, it is bound to all open streams on
   backtracking.
<P>
   If the stream is not a file, the Name argument has different
   meanings:  If it is the user's console, the pseudo file names
   'user' or 'error' are returned.  If the stream is a string stream,
   Name returns the current contents of the string stream.
<P>
   The following table illustrates the predefined symbolic system streams
   with the name, mode, and initial physical stream number that they are
   initially assigned to.
<P>
<PRE>
    Logical         Name         Mode    Number
    input           user         read    0
    stdin           user         read    0
    output          user         write   1
    stdout          user         write   1
    warning_output  user         write   1
    log_output      user         write   1
    error           error        write   2
    stderr          error        write   2
    null            null         update  3
</PRE>
<P>
   Also see set_stream/2 for details on how to assign a symbolic stream
   name to a physical stream, or to redirect a symbolic stream name.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>current_stream(-, -, -) is nondet
<LI>current_stream(-, -, +) is semidet
</UL>
<H3>Fail Conditions</H3>
Fails if Stream is not a stream
<H3>Exceptions</H3>
<DL>
<DT><EM>(5) type error </EM>
<DD>Name is instantiated, but not to an atom or a string.
<DT><EM>(5) type error </EM>
<DD>Mode is not an atom.
<DT><EM>(5) type error </EM>
<DD>Stream is instantiated, but not to an atom or an integer.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      current_stream(Name,Mode,Stream). % returns all
                                        %   open streams.

      [eclipse]: current_stream(error,Mode,Stream).
      Mode = write
      Stream = 2      More? (;)
      yes.

      [eclipse]: open(file,update,s), current_stream(file,M,s).
      M = update
      yes.

      [eclipse]: open(F,string(10),f), writeln(f, "bigstring"),
      &gt; current_stream(Data,M,f).
      F = "bigstring\n"
      Data = "bigstring\n"
      M = string
      yes.

Fail:
      open(file,update,f), current_stream("file",M,f).
      current_stream(X,no,Y).

Error:
      current_stream(12,Mode,String).     (Error 5).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/iostream/current_stream-1.html">current_stream / 1</A>, <A HREF="../../kernel/iostream/open-3.html">open / 3</A>, <A HREF="../../kernel/iostream/open-4.html">open / 4</A>, <A HREF="../../kernel/iostream/get_stream_info-3.html">get_stream_info / 3</A>
</BODY></HTML>
